<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html xmlns:th="" lang="zh-CN">
<%@include file="/WEB-INF/pages/base/include.jsp"%>
<body>
<div id="wrapper">
    <%@include file="/WEB-INF/pages/base/menu.jsp"%>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">账号管理</h3>
            </div>
        </div>
        <div class="row">
            <form class="form-horizontal" data-parsley-validate>
                <div class="col-lg-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">账号创建</div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12 col-md-12">
                                     <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">所属商城：</label>
                                         <div class="col-lg-6 col-md-6">
                                             <select class="form-control" id="mallList">
                                             		<c:forEach var="item" items="${mallList}" varStatus="status">
								                             <option value="${item.mallUuid}">${item.mallName}</option>
								                    </c:forEach>
                                            </select>
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">账号名：</label>
                                         <div class="col-lg-8">
                                             <input type="text" id="name" value="" onkeyup = "ValidateValue(this)">
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">密码：</label>
                                         <div class="col-lg-8">
                                         	 <input type="text" id="pwd" value="" onkeyup = "ValidateValue(this)">
                                       	</div>
                                  	 </div>
                                   </div>
                               </div>
                           </div>
                       </div>
                   <div class="clearfix"></div>
                   <a class="btn btn-primary" href="javascript:void(0);"
                      style="margin-left:15px;margin-bottom:30px;" onclick="create()">完成</a>
                   <a class="btn btn-default" href="${webPath}toManager"
                      style="margin-left:15px;margin-bottom:30px;">取消</a>
                </div>
            </form>
        </div>
    </div>
</div>
<script>	
	function ValidateValue(textbox) {
		var IllegalString = "[`~!#$^&*()=|{}':;',\\[\\].<>/?~！#￥……&*（）——|{}【】‘；：”“'。，、？-+@&%_]‘’";
		var textboxvalue = textbox.value;
		var index = textboxvalue.length - 1;
		var s = textbox.value.charAt(index);
		if (IllegalString.indexOf(s) >= 0) {
			s = textboxvalue.substring(0, index);
			textbox.value = s;
		}
	}
   	function create() {
   		
   		var type = "${type}";
		if(type == "3"){
			alert("当前账号无权限查看此功能");
			return;
		}
		
   		var mallUuid = $("#mallList option:selected").val();
   		var name = $("#name").val();
      	var pwd = $("#pwd").val();
  		var baseURL = "${webPath}/manager/create";
      	var json_package = {
           "head": {},
           "body": {
           	"mallUuid": mallUuid,
           	"name": name,
           	"pwd": pwd
           }
       	}
   		$.post(baseURL, {"json_package": JSON.stringify(json_package)}, function (result) {
          if (typeof result == 'string') result = JSON.parse(result);
          if (result.body.result == '1') {
              alert(result.body.description)
          } else {
        	  alert(result.body.description)
        	  location.href = "${webPath}toManager";
          }
      	})
	}
</script>
</body>
</html>
